package config

import (
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

type Product struct {
	gorm.Model
	Name     string
	Describe string
}

func InitDB() {

	dbPath := "test.db"
	db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
	if nil != err {
		panic("Failed to connect database")
	}

	err = db.AutoMigrate(&Product{})

	db.Create(&Product{
		Name:     "product",
		Describe: "product",
	})

	db.Delete(&Product{}, []uint{1})
}
